// 通用装备接口
const mongoose = require('mongoose');
const User = require('../models/User/User');
const Maps = require('../models/Map');
const battle_tools = require('../controller/tools/battle/battle');

exports.playerbattle = async (req, res) => {
    let target_id = req.params.id;
    let uid = req.user._id;
    console.log("战斗方法,进攻方、防守uid",uid,target_id);
    if(!uid || !target_id){
        return res.json({
            code: 0,
            msg: "战斗参数错误",
            data: null
        });
    }else{
        result = await battle_tools.battle_check(uid,'player',target_id);
        console.log("battle api player 结果",result);
        if(result = 0){
            return res.json({
                code: 0,
                msg: "战斗结束,Player胜利",
                data: null
            });
        }else{
            return res.json({
                code: 1,
                msg: "战斗结束,Target胜利",
                data: null
            });
        };
    }
}

